package com.nstar.orderexpress.view
{
	import mx.containers.HBox;
	import mx.events.FlexEvent;
	import mx.controls.LinkBar;
	import mx.events.ItemClickEvent;
	import mx.core.Application;
	import com.nstar.orderexpress.mxml.LoginView;
	import mx.managers.PopUpManager;
	import mx.controls.ComboBox;
	import mx.controls.Text;
	import com.nstar.base.util.DateUtils;
	import flash.utils.setInterval;

	public class InfoPanelClass extends HBox
	{
		public var lbLogin:LinkBar;
		public var txtUserName:Text;
		public var cboUserType:ComboBox;
		public var txtDateTime:Text;
		
		public function InfoPanelClass()
		{
			//TODO: implement function
			super();
			this.addEventListener(FlexEvent.CREATION_COMPLETE,init);
		}
		
		private function init(event:FlexEvent):void{
			lbLogin.addEventListener(ItemClickEvent.ITEM_CLICK,itemclickHandler);
			showDateTime();//先调用一次显示出时间
			setInterval(showDateTime,1000);
		}
		
		private function showDateTime():void{
			txtDateTime.text = DateUtils.format(new Date(),"YYYY-MM-DD HH:MS:SS")+" "
				+DateUtils.week();
		}
		
		private function itemclickHandler(event:ItemClickEvent):void{
			var app:* = Application.application;
			switch (event.index){
				case 0:
					var login:LoginView = LoginView(PopUpManager.createPopUp(app,LoginView,true));
					PopUpManager.centerPopUp(login);
					break;
				case 1:
					break;
			}
		}	
		
		private function genCharClass(char:String):Class{
			switch (char){
				case "0":return AppImages.number0;
				case "1":return AppImages.number1;
				case "2":return AppImages.number2;
				case "3":return AppImages.number3;
				case "4":return AppImages.number4;
				case "5":return AppImages.number5;
				case "6":return AppImages.number6;
				case "7":return AppImages.number7;
				case "8":return AppImages.number8;
				case "9":return AppImages.number9;
				case ".":return AppImages.numberDot;
				default :return null;
			}
		}	
	}
}